package com.hyh.admin.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.hyh.admin.domain.resources.ResourcesCommunity;
import com.hyh.admin.domain.resources.vo.CommunityVo;
import com.hyh.admin.mapper.resources.ResourcesCommunityMapper;
import com.hyh.admin.service.ResourcesCommunityService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;

@Service
public class ResourcesCommunityServiceImpl implements ResourcesCommunityService {

    @Autowired
    private ResourcesCommunityMapper resourcesCommunityMapper;

    @Override
    public int saveResourcesCommunity(ResourcesCommunity resourcesCommunity) {
        return resourcesCommunityMapper.insert(resourcesCommunity);
    }

    @Override
    public int updateResourcesCommunity(ResourcesCommunity resourcesCommunity) {
        return resourcesCommunityMapper.updateById(resourcesCommunity);
    }

    @Override
    public int deleteResourcesCommunity(Long id) {
        return resourcesCommunityMapper.deleteById(id);
    }

    @Override
    public ResourcesCommunity getResourcesCommunityById(Long id) {
        return resourcesCommunityMapper.selectById(id);
    }

    @Override
    public List<ResourcesCommunity> getAllResourcesCommunity(ResourcesCommunity resourcesCommunity) {
        LambdaQueryWrapper<ResourcesCommunity> queryWrapper = new LambdaQueryWrapper<>();
        return resourcesCommunityMapper.selectList(queryWrapper);
    }

    @Override
    public List<ResourcesCommunity> getResourcesByDeleteFlag(String deleteFlag) {
        // 这里可以根据删除标识查询资源
        // 例如：return resourcesCommunityMapper.selectByDeleteFlag(deleteFlag);
        return Collections.emptyList(); // 返回空列表作为示例
    }

    @Override
    public int deleteResourcesCommunityBatch(List<Long> ids) {
        if (ids == null || ids.isEmpty()) {
            return 0; // 如果没有ID，返回0
        }
        return resourcesCommunityMapper.deleteBatchIds(ids);
    }

    @Override
    public List<CommunityVo> getAllResourcesCommunityIncludeUsers() {
        return resourcesCommunityMapper.getAllResourcesCommunityIncludeUsers();
    }
}
